<template>
<h2>显示会员</h2>

姓名：
<input type="text" v-model="SouSuo.Mname">

手机号：
<input type="text" v-model="SouSuo.Phone">

身份证：
<input type="text" v-model="SouSuo.Huiy">

会员卡号：
<input type="text" v-model="SouSuo.Shenf">
等级:
<select  v-model="SouSuo.Did" >
                <option :value="-1">--请选择---</option>
                <option  v-for="item in ab" :value="item.dId" >{{ item.dName }}</option>
           </select>



        <button value="搜索" @click="SouSUo1">搜索</button>


<table class="table table-border">
<thead>
    <tr>
        <th>会员id</th>
        <th>会员姓名</th>
        <th>会员手机号</th>
        <th>本店消费</th>
        <th>会员生日</th>

            <th>会员身份证</th>
            <th>会员卡号</th>
            
        
        

        <th>等级</th>
        
        <th>操作</th>
     
    </tr>



</thead>

<tbody  v-for="item in aa">

    <tr >
        <th>{{item.mId}}</th>
        <th>{{item.mname}}</th>
        <th>{{item.phone}}</th>
        <th>￥{{ nn.toFixed(2) }}</th>
        <th>{{item.shengRi.substring(0,10)}}</th>
        <th>{{item.shenFenZheng}}</th>
        <th>{{item.huiYuanKa}}</th>
        <th>{{item.dName}}</th>
        
        <th><button class="btn btn-success" @click="IsDel(item.mId)">删除</button>
        
            <a href="#" @click="Xg(item.mId)">修改</a>
        
        </th>
    </tr>


</tbody>



</table>


</template>

<script setup lang="ts">

const nn =ref(100);

import axios from 'axios';
import{onMounted, ref} from 'vue';
import { useRoute,useRouter,createRouter} from 'vue-router';

    onMounted(()=>{
        ShowMe();

    })



const aa =ref([{
    mId: 0,
    mname: "",
    phone: "",
    mpwd: "",
    shengRi: "",
    shenFenZheng: "",
    huiYuanKa: "",
    did: -1,
    dName: ""


}])

const SouSuo =ref({

    Mname:"",
    Phone:"",
    Shenf:"",
    Huiy:"",
    Did:-1,




})
const ShowMe=()=>{


    axios.get('https://localhost:7010/api/Member/ShowME',{


        params:{
            
            Mname:SouSuo.value.Mname,
            Phone:SouSuo.value.Phone,
            Shenf:SouSuo.value.Shenf,
            Huiy:SouSuo.value.Huiy,
            Did:SouSuo.value.Did,
        
        
                }

    }).then(res=>{
    
        aa.value=res.data

    })

    .catch(x=>{

        console.log(x);
    })
        




}




const SouSUo1=()=>{

  
    ShowMe();
}


onMounted(()=>{

XiaLa()


})

const ab= ref([{


dId: -1,
dName: "--请选择---"


}])


const XiaLa=()=>{
    axios.get('https://localhost:7010/api/DengJI/ShowDj').then(res=>{

            
        ab.value=res.data;
    })
    .catch(error=>{
           
        console.log(error);
    })

}


const router =useRouter();

const IsDel=(Mid:number)=>{

    if(!confirm('确认删除吗'))
{
    return ;
}


    axios.delete('https://localhost:7010/api/Member/DelMe',{

        params:{

            Mid:Mid,
        }
    }).then(res=>{

            if(res.data>0)
            {
                alert('删除成功')
                ShowMe();
                
            }
            else
            {
                alert('删除失败')
            }

    }).catch(x=>{

        console.log(x);
    })







}





const Xg=(Mid:number)=>{

    router.push({
        name:'XgME',
        params:{

            M1id:Mid,
             

        }

    });


}

</script>